$(function(){
	//给所有主菜单添加点击后显示相应子菜单功能
	$(".main_menu").click(function(){
			//改变选择后的样式
			$(".main_menu").css('color','#333');
			$(this).css('color','#900');
			
			var panels = $('#menu_tree').accordion('panels');
			$('#upp_layout').layout('expand','west');
			while(panels.length > 0){
				$('#menu_tree').accordion('remove',0);
				panels = $('#menu_tree').accordion('panels');
			}
			var menusDom = $('#' + $(this).attr('title') + '_tree div[class="title"]');
			var menusLen = menusDom.length;
			if(menusLen > 0){
				for(var j=0;j < menusLen; j++){
					var menuDom = menusDom[j];
					$('#menu_tree').accordion('add',{
						title:$(menuDom).attr('title'),
						content:$(menuDom).html(),
						selected: false
					});
				}
				$('#menu_tree').accordion('select',0);
			}
		});
});
/**
 * 退出系统
 */
function logout(){
	$.messager.confirm("注销","你确定要退出系统吗",function(resp){
		if(resp){
			$.ajax({
				type:'post',
				url:contextPath + '/logout',
				complete:function(){
					toLogin();
				}
			});
		}
	});
}

$(document).ready(function(){
	if ($.cookie('easyuiThemeName')) { 
		$("#cb-theme").val($.cookie('easyuiThemeName'));
	}
	
	$('#upp_layout').layout('collapse','west');
});

/**
 * 弹出消息框，不用点击，自动消失
 * @param message
 */
function uppShow(message){
	$.messager.show({
		title : '消息',
		msg : message,
		showType : 'slide',
		style:{
			right : '',
			top : document.body.scrollTop + document.documentElement.scrollTop,
			bottom : ''
        }
	});
}